/*
    ejscript.me -- MakeMe file for Ejscript
 */

Me.load({
    blend: [ 'http', 'zlib' ],

    settings: {
        ejsOneModule: true,
    },

    targets: {
        ejscript: {
            configurable: true,
            depends:      [ 'libejs', 'zlib' ],
            requires:     [ 'zlib' ],
            uses:         [ 'sqlite' ],
        },

        libejs: {
            type:   'lib',
            sources: [ 'ejsLib.c' ],
            headers: [ '*.h' ],
            depends: [ 'libhttp', 'libpcre', 'libmpr', 'libzlib' ],
            uses:    [ 'sqlite' ],
            ifdef:   [ 'ejscript' ],
        },

        ejscmd: {
            pname:  'ejs',
            path:   '${BIN}/${settings.name}-ejs${EXE}',
            type:   'exe',
            sources: [ 'ejs.c' ],
            scripts: {
                prebuild: `
                    if (me.settings.compiler.hasLibEdit) {
                        me.target.libraries.push('edit')
                    }
                `,
            },
            depends: [ 'libejs' ],
            ifdef:   [ 'ejscript' ],
            enable: 'me.settings.ejscript.shell',
        },

        ejsc: {
            path:   '${BIN}/${settings.name}-ejsc${EXE}',
            type:   'exe',
            sources: [ 'ejsc.c' ],
            depends: [ 'libejs' ],
            ifdef:   [ 'ejscript' ],
        },

		'ejs.mod': {
            files: [ 'ejs.es' ],
            path: "${BIN}/ejs.mod",
            build: `
                run('"${LBIN}/${settings.name}-ejsc" --out "${BIN}/ejs.mod" ${settings.ejscript.compile} --bind --require null ${FILES}')
            `,
            message: 'Compile: ejs.mod',
            depends: [ 'ejsc' ],
            ifdef:   [ 'ejscript' ],
		}
    }
})
